﻿using Microsoft.AspNetCore.Mvc;
using System.Linq;
using YSC_Core.BLL.Domain.BackstageModels;
using YSC_Services.BLL.Services.Interfaces;

namespace YSC_Backstage_Web.Controllers
{
    /// <summary>
    /// 用户管理
    /// </summary>
    public class UserController : Controller
    {
        private IUserBackstageServices _rep;

        public UserController(IUserBackstageServices rep)
        {
            this._rep = rep;
        }

        //User
        //用户信息
        public IActionResult Index()
        {
            return View();
        }

        /// <summary>
        /// 后台用户列表
        /// </summary>
        /// <returns></returns>
        public IActionResult BackstageList()
        {
            return View();
        }

        public IActionResult Add()
        {
            return View();
        }

        /// <summary>
        /// 综合用户添加
        /// </summary>
        /// <returns></returns>
        public IActionResult BackstageAdd()
        {
            return View();
        }

        public IActionResult Edit(string Id)
        {
            return View();
        }

        public IActionResult PersonalInformationEdit()
        {
            return View();
        }

        /// <summary>
        /// 用户列表
        /// </summary>
        /// <param name="index"></param>
        /// <param name="size"></param>
        /// <param name="status">是否停用: -1 停用0: 正常 1: 认证用户 2:未认证</param>
        /// <param name="sasearch"></param>
        /// <param name="isAttest">认证类型 0 市场 1 :产地 </param>
        /// <returns></returns>
        public JsonResult GetUserAll(int index, int size, int status, string isAttest, string sasearch)
        {
            var ret = _rep.GetUserAll(index, size, status, isAttest, null, sasearch);
            return Json(ret);
        }

        /// <summary>
        /// 后台用户列表
        /// </summary>
        /// <param name="index"></param>
        /// <param name="size"></param>
        /// <param name="status"></param>
        /// <param name="isAttest"></param>
        /// <param name="sasearch"></param>
        /// <returns></returns>
        public JsonResult GetUserBackstageAll(int index, int size, int status, string isAttest, string areCode, string sasearch)
        {
            var ret = _rep.GetUserBackstageAll(index, size, status, isAttest, areCode, sasearch);
            return Json(ret);
        }


        /// <summary>
        /// 用户密码修改
        /// </summary>
        /// <param name="password"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public JsonResult GetUserPasswordChange(string oldPassword, string password, string userId)
        {
            var ret = _rep.GetUserPasswordChange(oldPassword, password, userId);
            return Json(ret);
        }
    }
}